import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.HashMap;


/**
 * @author Matt Adams
 */
public interface Node extends Remote {
  
    /**
     * Get this node's host and port information.
     * 
     * @return Returns HostPort object for this node.
     */
    public HostPort getNodeHostPort() throws RemoteException;
    
    /**
     * Get this node's id.
     * 
     * @return Returns this nodes id.
     */
    public int getNodeID() throws RemoteException;
    
    /**
     * Returns max number of nodes in chord.
     * 
     * @return Returns max number of nodes in chord.
     */
    public int getMaxNodesInChord() throws RemoteException;
    
    /**
     * Returns the chord node that is responsible for the given target node id.
     * 
     * @param targetNodeID The target node id.
     * @return Returns node responsible for given node id.
     */
    public abstract Node findSuccessor(final int targetNodeID) throws RemoteException;
    
    /**
     * Stores the object under its given id.
     * 
     * @param entry Entry being inserted.
     */
    public abstract void insertEntry(final Entry entry) throws RemoteException;
    
    /**
     * Removes the object based on its given id.
     * 
     * @param entry Entry being removed.
     */
    public abstract void removeEntry(final Entry entry) throws RemoteException;
    
    /**
     * Returns whether the queried object is contained in a list under the given id.
     * 
     * @param entry Entry being checked for contains.
     * @return Returns true if object is found in the list under the given id.
     */
    public abstract boolean containsEntry(final Entry entry) throws RemoteException;
    
    /**
     * Informs a node that its predecessor is leaving the chord.
     * 
     * @param predecessor Predecessor node leaving.
     */
    public abstract void leaveNetworkNotify(final Node predecessor) throws RemoteException;
    
    /**
     * Closes the connection to the node.
     */
    public abstract void disconnect() throws RemoteException;
    
    /**
     * Sets this node's host and port data.
     * 
     * @param nodeHostPort The host and port data for this node.
     */
    public void setNodeHostPort(final HostPort nodeHostPort) throws RemoteException;
    
    /**
     * Sets this node's id.
     * 
     * @param nodeID The node id.
     */
    public void setNodeID(final int nodeID) throws RemoteException;
    
    
    public NodeReferences getNodeReferences() throws RemoteException;
}
